<script type="text/javascript">
    // 快速搜索
    Search = function () {

    };

    // 删除多个用户
    DeleteByIds = function () {
        var ids = CheckBox.GetCheckedIds();

        //alert(ids.join(','));

        if (ids.length == 0) {
            jBox.tip("请选择至少一个用户！");
            return;
        }

        jBox.confirm("此操作不可恢复，确定要删除选中的用户吗？", "删除用户", function (v, h, f) {
            if (v == 'ok') {
                jBox.tip('正在处理...', 'loading');

                // 在这ajax处理
                window.setTimeout(function () {
                    jBox.tip('删除成功！', 'success');
                    Index.Open(location.href);
                }, 2000);
            }
            return true;
        });
    };
</script>
<body>
<div class="container">
  <div class="location">当前位置：常规管理 -&gt; 文章列表</div>
  <div class="blank10"></div>
  <div class="search block">
    <div class="h">
      <span class="icon-sprite icon-magnifier"></span>
      <h3>快速搜索</h3>
    </div>
    <div class="tl corner"></div><div class="tr corner"></div><div class="bl corner"></div><div class="br corner"></div>
    <div class="cnt-wp">
      <div class="cnt">
        <div class="search-bar">
          <label class="first txt-green">标题：</label>
          <input value="" type="text" name="username" id="username" class="input-big" />
          <label><a class="btn-lit btn-middle" href="javascript:Search();"><span>搜索</span></a></label>
        </div>
      </div>
    </div>
  </div>
  <div class="blank10"></div>
  <div class="block">
    <div class="h">
      <span class="icon-sprite icon-list"></span>
      <h3>用户列表</h3>
      <div class="bar">
        <%= link_to '<span>新增</span>'.html_safe, new_article_path,:class => 'btn-lit' %>
        <a class="btn-lit" href="javascript:DeleteByIds();"><span>删除选中</span></a>
      </div>
    </div>
    <div class="tl corner"></div><div class="tr corner"></div><div class="bl corner"></div><div class="br corner"></div>
    <div class="cnt-wp">
      <div class="cnt">
        <% if @articles.blank? %>
        <p align="center" style="padding:20px;font-size: 14px;">
          o(︶︿︶)o 唉，暂无记录。
        </p>
        <% else %>
        <!-- 有文章列表 -->
        <table class="data-table" width="100%" border="0" cellspacing="0" cellpadding="0">
          <tbody>
          <tr>
            <th scope="col"><input value="true" type="checkbox" title="全选/不选" onclick="CheckBox.CheckAll(this);" name="CheckAll" id="CheckAll" /><input value="false" type="hidden" name="CheckAll" /></th>
            <th scope="col">标题</th>
            <th scope="col">内容</th>
            <th scope="col">作者</th>
            <th scope="col">操作</th>
          </tr>
          <!-- 循环开始 -->
          <% @articles.each do |article| %>
              <tr class="<%= cycle("","even") %>">
                <td class="chk"><input value="true" type="checkbox" rel="2" name="CheckBox" class="check-box" /><input value="false" type="hidden" name="CheckBox" /></td>
                <td class="txt80 c"><%= truncate article.title,:length => 15 %></td>
                <td class="txt200 c"><%= truncate strip_tags(article.body),:length => 30 %></td>
                <td class="txt40 c">
                  <% if article.author.empty? %>
                      管理员
                  <% else %>
                      <%= article.author %>
                  <% end %>
                </td>
                <td class="icon">
                  <%= link_to '编辑',edit_article_path(article) %>
                  <%= link_to '删除',article, method: :delete, data: { confirm: '确认删除吗？数据删除后无法恢复！' } %>
                </td>
              </tr>
          <% end %>
          <!-- 循环结束 -->
          </tbody>
        </table>
        <!-- 文章列表结束 -->
        <% end %>
      </div>
    </div>
  </div>
  <div class="pages">
    <%= will_paginate @articles %>
  </div>
</div>
<% if !notice.blank? %>
<script type="text/javascript">
  jBox.tip("<%= notice %>");
</script>
<% end %>
</body>